//using System;
//using System.Collections.Generic;
//using System.Text;

//using agsXMPP;
//using agsXMPP.protocol.client;
//using agsXMPP.protocol.x.muc;

//namespace PoshXmpp
//{
//    class Program
//    {
//        static void Main(string[] args)
//        {
//            const string JID_SENDER = "PowerBot@im.flosoft.biz";
//            const string PASSWORD = "SuperBot";   // password of the JIS_SENDER account

//            const string JID_RECEIVER = "Jaykul@im.flosoft.biz";

//            Jid jidSender = new Jid(JID_SENDER);
//            XmppClientConnection xmpp = new XmppClientConnection(jidSender.Server);
//            xmpp.AutoAgents = false;
//            xmpp.AutoRoster = false;
//            //xmpp.AutoResolveConnectServer = true;
//            xmpp.SocketConnectionType = agsXMPP.net.SocketConnectionType.HttpPolling;
//            xmpp.ConnectServer = "http://im.flosoft.biz:5280/http-poll/";

//            //  XmppClientConnection xmpp = ConnectHandler.CreateXmppConnection(JID_SENDER, PASSWORD, "http://im.flosoft.biz:5280/http-poll/");

//            //xmpp.OnLogin += delegate(object o) {
//            //    //xmpp.PresenceManager.ApproveSubscriptionRequest(new agsXMPP.Jid(JID_RECEIVER));
//            //    xmpp.Show = ShowType.chat;
//            //    xmpp.Status = "Here I am";
//            //    xmpp.SendMyPresence();
//            //    xmpp.Send(new Message(new Jid(JID_RECEIVER), MessageType.chat, "Hello, how are you?")); 
//            //};

//            MessageManager mq = new MessageManager(xmpp);
//            MucManager muc = new MucManager(xmpp);

//            Jid chat = new Jid("powershell%irc.freenode.net@irc.im.flosoft.biz");
//            Jid owner = new Jid(JID_RECEIVER);

//            xmpp.OnLogin += delegate(object o)
//            {
//                xmpp.Show = ShowType.chat;
//                xmpp.Status = "I'm a chatterbot";
//                xmpp.SendMyPresence();

//                muc.JoinRoom(chat, "PoshBot[Mirror]");


//                //xmpp.PresenceManager.ApproveSubscriptionRequest(new agsXMPP.Jid(JID_RECEIVER));
//                xmpp.Send(new Message(chat, MessageType.groupchat, "I can haz cookie?"));

//                xmpp.Send(new Message(owner, MessageType.chat, "Hello, how are you?"));
//            };

//            xmpp.Open(jidSender.User, PASSWORD);

//            Console.WriteLine("Press any key to exit!");
//            while (!Console.KeyAvailable)
//            {
//                foreach (Message m in mq.Messages)
//                {
//                    if (m.From.Bare.ToLower().Equals(owner.Bare.ToLower()))
//                    {
//                        xmpp.Send(new Message(chat, MessageType.groupchat, string.Format(m.Body)));
//                    }
//                    else
//                    {
//                        xmpp.Send(new Message(owner, MessageType.chat, string.Format("<{0}> {1}", m.From.Resource, m.Body)));
//                    }
//                }
//                System.Threading.Thread.Sleep(200);
//            }

//            muc.LeaveRoom(chat, "I am so gone");
//            xmpp.Close();
//        }
//    }
//}